package com.buymobile.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.buymobile.dao.ValueDAO;
import com.buymobile.domain.Value;
import com.buymobile.service.ValueService;
import com.buymobile.utils.Constant;

public class ValueServiceImpl implements ValueService {

	private ValueDAO valueDAO; 
	
	@Override
	public Value getValueById(Integer id) {
		return (Value)valueDAO.queryForObject("value.getValueById",id);
	}
	
	@Override
	public void addValue(Value value) {
		valueDAO.insert("value.insertValue",value);
		
	}

	@Override
	public List<Value> getValuesByPropertyId(Integer propertyId) {
		Map<String,Object> criteria = new HashMap<String,Object>();
		criteria.put(Constant.ORDER_BY_CLAUSE, "order by id");
		criteria.put("property_id",propertyId);
		return (List<Value>)valueDAO.queryForList("value.queryValues", criteria);
		
	}

	@Override
	public void updateValue(Value value) {
		valueDAO.update("value.updateValue",value);
		
	}

	public void setValueDAO(ValueDAO valueDAO) {
		this.valueDAO = valueDAO;
	}

}
